home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 340 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mudskipper.cac.psu.edu!user
  2. From: fcusack@tdx.org (frank.)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is '?' in C mean....?????
  5. Date: Thu, 04 Jan 1996 11:15:54 -0500
  6. Organization: Penn State University, Center for Academic Computing
  7. Message-ID: <fcusack-0401961115540001@mudskipper.cac.psu.edu>
  8. References: <4cgsa8$bm2@wumpus.cc.uow.edu.au>
  9. NNTP-Posting-Host: mudskipper.cac.psu.edu
  10.  
  11. In article <4cgsa8$bm2@wumpus.cc.uow.edu.au>, tp86@wumpus.cc.uow.edu.au
  12. (PAOPENG THEERADECH) wrote:
  13.  
  14. > Hello to all.
  15. >         I got something here to ask you guys. I saw some symbol like "?" be
  16. > used in some codes. I don't understand what does it mean. I tried to read some
  17. > text books but I still cannot find the detail about "?". The codes that I saw 
  18. > are;
  19. >                 max = x>y ? x:y;
  20. >                 
  21. >                         and
  22. >                 printf("%d", x>y ? x:y);
  23. > Could anyone here explain to me what is "?" means and what the purpose
  24. of using
  25.  
  26. You can probably find this info in the FAQ!!!!
  27.  
  28. ? : is C's ternary operator. if the condition is met, perform the
  29. operation after the ?; if the condition is not met, perform the operation
  30. after the :
  31.  
  32. eg: ("pseudo"code)
  33.  
  34. did you read the FAQ ? pat yourself on back : read before posting
  35. ~Frank
  36.  
  37.  --     Does Santa exist? --> http://www.tdx.org/~fcusack/santa.html      --
  38.  -- PGP key fingerprint: 4D 31 4E 12 8B 3A 00 B2  61 20 56 BA 90 FA 35 3B --
  39.